﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace e2
{
    [Serializable]
    public class Order
    {
        private List<Good> good;
        private OrderDetails details;

        public List<Good> Goods { get => good; set => good = value; }
        public OrderDetails Details { get => details; set => details = value; }

        public Order()
        {

        }
        public Order(List<Good> goods, OrderDetails details)
        {
            Goods = goods;
            Details = details;
        }
        public double Money()
        {
            double res = 0;
            for (int i = 0; i < Goods.Count; i++)
                res += Goods[i].Price * Goods[i].Num;
            return res;
        }

        public override bool Equals(object obj)
        {
            Order order = obj as Order;
            return order != null && order.details.Id == details.Id && order.Goods == Goods;
        }
        public override int GetHashCode()
        {
            return Details.GetHashCode() * 10 + Goods.Count;
        }
        public override string ToString()
        {
            string res = details.ToString();
            for (int i = 0; i < Goods.Count; i++)
                res += Goods[i].ToString();
            return res;
        }

    }
}
